/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 */

package com.xci.edu.core.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.github.lvyanyang.core.BaseEntity;
import com.github.lvyanyang.core.BaseOperateUserEntity;
import com.github.lvyanyang.core.Const;
import com.github.lvyanyang.core.XCI;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import java.util.Date;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 课程信息
 * @author 焦元义 jiaoyuanyi@xci96716.com
 * @since 2020-11-24 15:14:37
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "课程信息")
public class EduCourseware extends BaseOperateUserEntity {
    /**
     * 课程主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ExcelIgnore
    @Excel(name = "课程主键", width = 20d)
    @ApiModelProperty(value = "课程主键", position = 1)
    private Long id;

    /**
     * 课程名称
     */
    @NotBlank(message = "课程名称不能为空")
    @Length(max = 50, message = "课程名称长度不能超过{max}个字符")
    @Excel(name = "课程名称", width = 20d)
    @ApiModelProperty(value = "课程名称", required = true, position = 2)
    private String name;

    /**
     * 本章节学时(秒)
     */
    @NotNull(message = "本章节学时(秒)不能为空")
    @Excel(name = "本章节学时(秒)", width = 20d)
    @ApiModelProperty(value = "本章节学时(秒)", required = true, position = 3)
    private Integer period;

    @ApiModelProperty("本章节学时(时分秒)")
    public String getPeriodToText() {
        return  XCI.toJsonString(period /3600) + "时" +XCI.toJsonString(period % 3600 / 60)  + "分" + XCI.toJsonString(period % 3600 % 60)  + "秒";
    }

    /**
     * 科目主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "科目主键不能为空")
    @Excel(name = "科目主键", width = 20d)
    @ApiModelProperty(value = "科目主键", required = true, position = 4)
    private Long eduCategoryId;

    /**
     * 科目名称
     */
    @NotBlank(message = "科目名称不能为空")
    @Length(max = 50, message = "科目名称长度不能超过{max}个字符")
    @Excel(name = "科目名称", width = 20d)
    @ApiModelProperty(value = "科目名称", required = true, position = 5)
    private String eduCategoryName;

    /**
     * 课件类型[0-图片, 1-视频]
     */
    @NotBlank(message = "课件类型不能为空")
    @Length(max = 50, message = "课件类型长度不能超过{max}个字符")
    @Excel(name = "课件类型", width = 20d, replace = { "图片_0", "视频_1" })
    @ApiModelProperty(value = "课件类型[0-图片, 1-视频]", required = true, position = 6)
    private String courseType;

    @ApiModelProperty("课件类型")
    public String getCourseTypeName() {
        switch(this.courseType) {
            case "0":
                return "图片";
            case "1":
                return "视频";
            default:
                return "";
        }
    }

    /**
     * 排序号
     */
    @NotNull(message = "排序号不能为空")
    @Excel(name = "排序号", width = 20d)
    @ApiModelProperty(value = "排序号", required = true, position = 7)
    private Integer path;

}
